<template>
  <div class="home">
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
      <van-swipe-item v-for="item in lunbolist" :key="item.id"
        ><img :src="item.img"
      /></van-swipe-item>
    </van-swipe>
    <div class="title">
      <van-grid :column-num="3" gutter="10">
        <van-grid-item
          v-for="value in grids"
          :key="value.id"
          :icon="value.src"
          :text="value.title"
          :to="value.to"
        />
      </van-grid>
    </div>
  </div>
</template>

<script>
// @ is an alias to /src

export default {
  name: 'Home',
  data() {
    return {
      lunbolist: [],
      grids: []
    }
  },
  methods: {
    async getlunbolist() {
      const res = await this.$http.getlunbo()
      this.lunbolist = res.message
    },
    async getGrids() {
      const res = await this.$http.grids()
      this.grids = res.message;
    }
  },
  created() {
    this.getlunbolist();
    this.getGrids();
    this.$store.state.Show = true
  },
  beforeDestroy() {
    this.$store.state.Show = false
  },
}
</script>

<style lang='scss'>
.my-swipe .van-swipe-item {
  color: #fff;
  font-size: 20px;
  height: 150px;
  text-align: center;
  img {
    width: 100%;
    height: 100%;
  }
}
.title {
  margin-top: 40px;
  .van-grid-item__text {
    color: red;
    font: 22px;
  }
}
</style>